#!coding:utf-8
"""
    @author jay.han
    The various power states that a VM can be in.
    VIR_DOMAIN_NOSTATE = 0
    VIR_DOMAIN_RUNNING = 1
    VIR_DOMAIN_BLOCKED = 2
    VIR_DOMAIN_PAUSED = 3
    VIR_DOMAIN_SHUTDOWN = 4
    VIR_DOMAIN_SHUTOFF = 5
    VIR_DOMAIN_CRASHED = 6
"""

NOSTATE = 0x00
RUNNING = 0x01
BLOCKED = 0x02
PAUSED = 0x03
SHUTDOWN = 0x04
SHUTOFF = 0x05
CRASHED = 0x06


SUSPENDED = 0x07
FAILED = 0x08
BUILDING = 0x09
DELETED = 0x0a
SAVED = 0x0b
ERROR = 0x0c


MIRGRATE=0x77

_STATE_MAP = {
    NOSTATE: 'nostate',
    RUNNING: 'running',
    BLOCKED: 'blocked',
    PAUSED: 'paused',
    SAVED: 'saved',
    SHUTDOWN: 'shutdown',
    SHUTOFF: 'shutdown',
    CRASHED: 'crashed',
    SUSPENDED: 'suspended',
    FAILED: 'failed',
    BUILDING: 'building',
    DELETED: 'deleted',
    ERROR: 'error',
    MIRGRATE:'migrating',
}


def name(code):
    return _STATE_MAP[code]


def valid_states():
    return _STATE_MAP.keys()
